﻿<UserControl x:Class="MyAnimelistRecommender.Controls.TabControls.Animes"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="600" d:DataContext="{d:DesignData /SampleData/RecommendationModelSampleData3.xaml}" Background="White">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/PresentationFramework.Aero, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
                <ResourceDictionary Source="/Resource/Style.xaml" />
                <ResourceDictionary Source="/Resource/Brush.xaml" />
                <ResourceDictionary Source="/Resource/Converter.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <CollectionViewSource x:Key="GroupedAnimeList" Source="{Binding AnimeList}">
                <CollectionViewSource.SortDescriptions>
                    <cm:SortDescription PropertyName="Title" Direction="Ascending"/>
                </CollectionViewSource.SortDescriptions>
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="GroupTitle" />
                </CollectionViewSource.GroupDescriptions>
            </CollectionViewSource>
            <DataTemplate x:Key="animalTemplate">
                <Grid Visibility="{Binding IsNotDropped, Converter={StaticResource BooleanToVisibilityConverter}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" SharedSizeGroup="sadsd" />
                        <ColumnDefinition Width="auto" SharedSizeGroup="safhdjfhsdja" />
                    </Grid.ColumnDefinitions>
                    <CheckBox Grid.Column="0" Content="{Binding Title}"
                                      FontWeight="Bold" Margin="0,0,10,0"
                                      IsChecked="{Binding IsActivated}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                        <CheckBox.BindingGroup>
                            <BindingGroup Name="LalalaLand" SharesProposedValues="True" />
                        </CheckBox.BindingGroup>
                    </CheckBox>
                    <TextBlock Grid.Column="1"><Run Text=" "/><Run Text=" "/><Run Text="Score:"/><Run Text=" "/><Run Text=" "/><Run Text="{Binding Score}"/></TextBlock>
                </Grid>
            </DataTemplate>
            <HierarchicalDataTemplate x:Key="categoryTemplate" ItemsSource="{Binding Path=Items}" ItemTemplate="{StaticResource animalTemplate}">
                <TextBlock Text="{Binding Path=Name}"/>
            </HierarchicalDataTemplate>
            <Style x:Key="TreeViewItemFocusVisual">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Rectangle/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>
            <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
                <Setter Property="Focusable" Value="False"/>
                <Setter Property="Width" Value="16"/>
                <Setter Property="Height" Value="16"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                            <Border Background="Transparent" Height="16" Padding="5,5,5,5" Width="16">
                                <Path x:Name="ExpandPath" Data="{StaticResource TreeArrow}" Fill="Transparent" Stroke="#FF989898">
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="135" CenterY="3" CenterX="3"/>
                                    </Path.RenderTransform>
                                </Path>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
                                    <Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
                                </Trigger>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter Property="RenderTransform" TargetName="ExpandPath">
                                        <Setter.Value>
                                            <RotateTransform Angle="180" CenterY="3" CenterX="3"/>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
                                    <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="TreeViewItemStyle1" TargetType="{x:Type TreeViewItem}">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                <Setter Property="Padding" Value="1,0,0,0"/>
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TreeViewItem}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition MinWidth="19" Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Horizontal" d:LayoutOverrides="Height">
                                    <ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ExpandCollapseToggleStyle}" Visibility="{Binding ItemCount, Converter={StaticResource GreaterThanOneToVisibilityConverter}}" Margin="1.5,0" d:LayoutOverrides="Height"/>
                                    <CheckBox Content="" Margin="0" d:LayoutOverrides="Width" IsChecked="{Binding Items, Converter={StaticResource GroupCheckboxConverter}, Mode=OneWay}"  />
                                </StackPanel>
                                <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                    <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Border>
                                <ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsExpanded" Value="false">
                                    <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
                                </Trigger>
                                <Trigger Property="HasItems" Value="false">
                                    <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="true">
                                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="IsSelectionActive" Value="false"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                                </MultiTrigger>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
                        <Setter Property="ItemsPanel">
                            <Setter.Value>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel/>
                                </ItemsPanelTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <ListBox Background="Transparent" BorderThickness="0" ItemsSource="{Binding AnimeList}" Margin="0" SelectionMode="Extended" BorderBrush="{x:Null}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Visibility="{Binding IsNotDropped, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" SharedSizeGroup="sadsd" />
                            <ColumnDefinition Width="auto" SharedSizeGroup="safhdjfhsdja" />
                        </Grid.ColumnDefinitions>
                        <CheckBox Grid.Column="0" Content="{Binding Title}"
                                      FontWeight="Bold" Margin="0,0,10,0"
                                      IsChecked="{Binding IsActivated}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                            <CheckBox.BindingGroup>
                                <BindingGroup Name="LalalaLand" SharesProposedValues="True" />
                            </CheckBox.BindingGroup>
                        </CheckBox>
                        <TextBlock Grid.Column="1"><Run Text=" "/><Run Text=" "/><Run Text="Score:"/><Run Text=" "/><Run Text=" "/><Run Text="{Binding Score}"/></TextBlock>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TreeView ItemsSource="{Binding Source={StaticResource GroupedAnimeList}, Path=Groups}" ItemTemplate="{StaticResource categoryTemplate}" ItemContainerStyle="{DynamicResource TreeViewItemStyle1}">
        </TreeView>
    </Grid>
</UserControl>